package com.galen.manual.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
// import lombok.Data;
// import lombok.EqualsAndHashCode;

import java.time.LocalDateTime;

// @Data
// @EqualsAndHashCode(callSuper = true)
@TableName("sms_codes")
public class SmsCode extends BaseEntity {

    @TableField("phone")
    private String phone;

    @TableField("code")
    private String code;

    @TableField("business_type")
    private String businessType; // login-登录，register-注册，reset_password-重置密码

    @TableField("ip_address")
    private String ipAddress;

    @TableField("expire_time")
    private LocalDateTime expireTime;

    @TableField("used")
    private Boolean used; // false-未使用，true-已使用

    @TableField("used_time")
    private LocalDateTime usedTime;

    // Getters and Setters
    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getBusinessType() {
        return businessType;
    }

    public void setBusinessType(String businessType) {
        this.businessType = businessType;
    }

    public String getIpAddress() {
        return ipAddress;
    }

    public void setIpAddress(String ipAddress) {
        this.ipAddress = ipAddress;
    }

    public LocalDateTime getExpireTime() {
        return expireTime;
    }

    public void setExpireTime(LocalDateTime expireTime) {
        this.expireTime = expireTime;
    }

    public Boolean getUsed() {
        return used;
    }

    public void setUsed(Boolean used) {
        this.used = used;
    }

    public LocalDateTime getUsedTime() {
        return usedTime;
    }

    public void setUsedTime(LocalDateTime usedTime) {
        this.usedTime = usedTime;
    }

    @Override
    public void preInsert() {
        super.preInsert();
        // 短信验证码特定的初始化逻辑
        if (this.used == null) {
            this.used = false;
        }
    }
}